<template>
    <div class="noInterview">
    <div class="noInterview-header">
      <div class="noInterview-header-left" @click="goBack">
        <i class="el-icon-arrow-left"></i>
        <span>返回</span>
      </div>
    </div>
    <div class="noInterview-content">
      <div class="content-title">
        <div class="content-title-left">
          <span>企业邀约人数</span>
          <span>({{total}})</span>
        </div>
        <div class="content-title-right">
          <div class="export-btn" @click="exportData">
            <img src="../../../assets/img/export.png" alt>
            <span>导出</span>
          </div>
        </div>
      </div>
      <div v-loading="loading">
        <el-table stripe border :data="tableData" size="small">
          <el-table-column label="会员名称" align="center">
            <template slot-scope="scope">
              <el-button
                @click="handleClickNickName(scope.row)"
                type="text"
                size="small"
              >{{scope.row.nickname}}</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="sex" label="性别" align="center"></el-table-column>
          <el-table-column prop="age" label="年龄" align="center"></el-table-column>
          <el-table-column prop="jobstatus" label="状态" align="center"></el-table-column>
          <el-table-column prop="positionname" label="邀约岗位" align="center"></el-table-column>
          <el-table-column prop="insertdate" label="邀约时间" align="center"></el-table-column>
        </el-table>
        <div style="padding: 20px;">
          <el-pagination
            background
            :current-page="form.pagenum"
            :page-size="form.pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            :page-sizes="[10, 20, 30, 50, 100]"
            @current-change="handleCurrentChange"
            @size-change="handleSizeChange"
          ></el-pagination>
        </div>
      </div>
      <el-dialog :visible.sync="dialogVisible" width="1040px">
        <resume-detail
          v-if="dialogVisible"
          :userid="userid"
          :nickName="nickName"
          :isShowTelphone="true"
        ></resume-detail>
      </el-dialog>
    </div>
  </div>
</template>
<script>
export default {
  name: "failInterview",
  components: {
      resumeDetail: () => import("../../../component/resumeDetail/index.vue"),
  },
  data() {
    return {
      loading: false,
      tableData: [],
      form: {
        pagenum: 1,
        pagesize: 10,
        companyid: "",
		idname:'interviewid'
      },
      total: 0,
      dialogVisible: false,
      userid: "",
      nickName: ""
    };
  },
  created() {
    this.form.companyid = this.$route.params.companyid;
    this.getTableData();
  },
  methods: {
    goBack() {
      this.$router.push({
        name: "employmentList"
      })
    },
    getTableData() {
      this.loading = true;
      this.$axios.post("/app/v1/platform/company/companyInviteList", this.form).then(res => {
        this.loading = false;
        if (res.data.code === 1) {
          this.tableData = res.data.data.list;
          this.total = parseInt(res.data.data.totalnum);
        } else {
          this.$message({
            message: res.data.message,
            type: "error"
          });
        }
      });
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pagenum = val;
      this.getTableData();
    },
    handleSizeChange(val) {
      this.form.pagenum = 1;
      this.form.pagesize = val;
      this.getTableData();
    },
    // 查看会员详情
    handleClickNickName(row) {
      this.userid = row.userid;
      this.nickName = row.nickname;
      this.dialogVisible = true;
    },
    // 导出
    exportData() {
      this.$axios({
        method: 'post',
        url: '/app/v1/platform/statistic/companyInviteListOut',
        data: this.form,
        responseType: 'blob'
      }).then(res => {
        this.download(res)
      }).catch((error) => {
        this.$message({
          message: '导出失败',
          type: 'error'
        });
      })
    },
    download(res) {
      if (!res) {
        return
      }
      let bob = new Blob([res.data]);
      let fileName = (res.headers['content-disposition']).split('=')[1];
      fileName = decodeURI(fileName)
      let url = window.URL.createObjectURL(bob)
      let link = document.createElement('a')
      link.style.display = 'none'
      link.href = url
      link.setAttribute('download', fileName)
      document.body.appendChild(link)
      link.click()
    }
  }
};
</script>

<style scoped>
.noInterview {
  min-width: 950px;
  padding: 10px;
}

.noInterview-header {
  font-size: 18px;
  line-height: 50px;
  background-color: #fff;
  box-sizing: border-box;
  padding-left: 20px;
  padding-right: 20px;
  border-bottom: 1px solid #d2d2d2;
}

.noInterview-header-left {
  width: 100px;
  cursor: pointer;
}

.noInterview-header-left i {
  color: #0064e4;
}

.noInterview-header-left span {
  color: #a1a1a1;
}

.noInterview-content {
  padding-left: 20px;
  padding-right: 20px;
  background-color: #fff;
}

.content-title {
  display: flex;
  justify-content: space-between;
}

.content-title-left {
  font-size: 18px;
}

.content-title-left::before {
  content: "";
  border-left: 12px solid #0064e4;
  margin-right: 10px;
  line-height: 60px;
}

.content-title-right {
  display: flex;
  align-items: center;
}
</style>
